package com.example.work_02;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SystemActivity extends AppCompatActivity {
    EditText ori;
    EditText navigation;
    EditText touch;
    EditText mnc;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.system);
        ori=(EditText) findViewById(R.id.et_01);
        navigation=(EditText) findViewById(R.id.et_02);
        touch=(EditText) findViewById(R.id.et_03);
        mnc=(EditText) findViewById(R.id.et_04);
        Button btn=(Button) findViewById(R.id.btn_08);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Configuration cfg=getResources().getConfiguration();
                String screen=cfg.orientation==Configuration.ORIENTATION_LANDSCAPE?"横屏":"竖屏";
                String naviName=cfg.orientation==Configuration.NAVIGATION_NONAV?"没有方向控制":cfg.orientation==Configuration.NAVIGATION_WHEEL?"滚轮控制方向":cfg.orientation==Configuration.NAVIGATION_DPAD?"方向键控制方向":"轨迹球控制方向";
                navigation.setText(naviName);
                String mncCode = cfg.mnc + "";
                String touchName = cfg.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH ? "无触摸屏": cfg.touchscreen == Configuration.TOUCHSCREEN_STYLUS ? "触摸笔式触摸屏": "接受手指的触摸屏";
                mnc.setText(mncCode);
                ori.setText(screen);
                touch.setText(touchName);
            }
        });
        Button btn01=(Button) findViewById(R.id.btn_09);
        btn01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(SystemActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });
}
}
